/**
 * 功能描述
 */

define(function (require, exports, module) {
	var QuestionnaireProfile_Events=require("../handler/QuestionnaireProfile_Events")
    var IntentionRegister_Events=require("../handler/IntentionRegister_Events")

    module.exports = {
        showDetail : function(widget,data,disabled,type){
        	widget.get("form").reset();
        	widget.get("form").setDisabled(disabled);
			widget.show([".J-tab"]).hide([".J-grid"]);
			widget.get("subnav").hide(["add","visitTime","status","intention","productType","product","search"]).show(["return","save"]);							
			if(disabled){
        		widget.get("subnav").hide(["save"]);
        	}
			if(!type){
				widget.get("form").setData(data);
				widget.get("form").setValue("product",data.productType.product);
				IntentionRegister_Events.changeProduct(widget,data.productType.pkProductType);
				if(data.questionAnswerSheet){
					QuestionnaireProfile_Events.setQuestionaire(data.questionAnswerSheet,widget);
				}
			}else{
				widget.get("profile").reset();
				widget.$(".J-other-answer").val("");
				widget.get("form").setValue("type",type);
			}
			IntentionRegister_Events.changeBirthday(widget,data.customer.personalInfo.birthday);
			/**
			 * 人员信息赋值
			 * 这垃圾代码……
			 */
			widget.get("form").setValue("pkCustomer",data.customer.pkCustomer);
			widget.get("form").setValue("customerVersion",data.customer.version);
			widget.get("form").setValue("personalInfo.name",data.customer.personalInfo.name);
			widget.get("form").setValue("personalInfo.sex",data.customer.personalInfo.sex);
			widget.get("form").setValue("personalInfo.idNumber",data.customer.personalInfo.idNumber);
			widget.get("form").setValue("personalInfo.birthday",data.customer.personalInfo.birthday);
			widget.get("form").setValue("personalInfo.mobilePhone",data.customer.personalInfo.mobilePhone);
			widget.get("form").setValue("personalInfo.houseRegister",data.customer.personalInfo.houseRegister);
			widget.get("form").setValue("personalInfo.address",data.customer.personalInfo.address);
			widget.get("form").setValue("personalInfo.electronicMail",data.customer.personalInfo.electronicMail);
			widget.get("form").setValue("organization",data.customer.organization.pkOrganization);
			widget.get("form").setValue("personalInfo.pkPersonalInfo",data.customer.personalInfo.pkPersonalInfo);
			widget.get("form").setValue("personalInfo.version",data.customer.personalInfo.version);
			widget.get("form").setValue("saleConsultant",data.saleConsultant.pkUser);
			widget.get("form").setValue("recordType",data.recordType.key);
			widget.get("form").setValue("wechat",data.customer.wechat);
			widget.get("form").setValue("qq",data.customer.qq);
			widget.get("form").setValue("zipCode",data.customer.zipCode);
		},
    };
});
